﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:c="clr-namespace:SharePointLogViewer.Controls">

    <Style  x:Key="ListItemRolloverHighlight" TargetType="{x:Type ListViewItem}">
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Background" Value="LightGray" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <!-- Create a stylised filter button -->
    <DataTemplate x:Key="filterButtonInactiveTemplate">
        <Path Fill="DarkGray" HorizontalAlignment="Center" VerticalAlignment="Center" Data="M 0 0 L 4 4 L 8 0 Z"/>
    </DataTemplate>
    
    <!-- Create a stylised filter button -->
    <DataTemplate x:Key="filterButtonActiveTemplate">
        <Path Fill="Black" HorizontalAlignment="Center" VerticalAlignment="Center" Data="M 0 0 L 4 4 L 8 0 Z"/>
    </DataTemplate>

    <Style x:Key="HeaderTemplateArrowUp" TargetType="{x:Type Label}">
        <Setter Property="Margin" Value="5,0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Label">
                    <Path x:Name="arrow" StrokeThickness = "1" Fill = "Gray" Data = "M 5,10 L 15,10 L 10,5 L 5,10"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="HeaderTemplateArrowDown" TargetType="{x:Type Label}">
        <Setter Property="Margin" Value="5,0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Label">
                    <Path x:Name="arrow" StrokeThickness = "1" Fill = "Gray" Data = "M 5,5 L 10,10 L 15,5 L 5,5"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="HeaderTemplateTransparent" TargetType="{x:Type Label}">
        <Setter Property="Margin" Value="5,0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Label">
                    <Path x:Name="arrow" StrokeThickness = "1" Fill = "Transparent" Data = "M 5,10 L 15,10 L 10,5 L 5,10"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <DataTemplate x:Key="FilterGridHeaderTemplate" >
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <!-- render the header text -->
            <TextBlock Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding}"/>
            <!-- add a lael which is used to display the sort indicator -->
            <Label Grid.Column="1" Name="sortIndicator" VerticalAlignment="Center" Style="{StaticResource HeaderTemplateTransparent}"/>            
            <!-- Add a filter button and popup  -->
            <Button Grid.Column="3" HorizontalAlignment="Right" ContentTemplate="{StaticResource filterButtonInactiveTemplate}" Name="filterButton"                     
                    Command="{x:Static c:FilterableListView.ShowFilter}"/>
            <Popup StaysOpen="false" Name="filterPopup" Placement="Bottom" PlacementTarget="{Binding ElementName=filterButton}">
                <ListView x:Name="filterList" ItemsSource="{Binding}"                               
                               BorderThickness="1" ItemContainerStyle="{StaticResource ListItemRolloverHighlight}">
                    <ListView.View>
                        <GridView>
                            <!-- hide the column header -->
                            <GridView.ColumnHeaderContainerStyle>
                                <Style TargetType="GridViewColumnHeader">
                                    <Setter Property="Visibility" Value="Hidden" />
                                    <Setter Property="Height" Value="0" />
                                </Style>
                            </GridView.ColumnHeaderContainerStyle>
                            <GridViewColumn DisplayMemberBinding="{Binding Path=ItemView}"/>
                        </GridView>
                    </ListView.View>
                </ListView>
            </Popup>
        </Grid>
    </DataTemplate>
    
    <DataTemplate x:Key="SortableGridHeaderTemplate" >
        <DockPanel >
            <TextBlock DockPanel.Dock="Left" VerticalAlignment="Center" Text="{Binding}"/>
            <Label Name="sortIndicator" DockPanel.Dock="Right" VerticalAlignment="Center" Style="{StaticResource HeaderTemplateTransparent}"/>                        
        </DockPanel>
    </DataTemplate>




</ResourceDictionary>